﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace HWR_Ants.Classes.Obsolete_2
{
    [Obsolete]
    class DistanceTable
    {
        double[,] distanceMatrix;
        int citiesCount;

        public DistanceTable(IList<Point> ListOfCities)
        {
            citiesCount = ListOfCities.Count;
            distanceMatrix = new double[citiesCount, citiesCount];
            fillMatrix(ListOfCities);
        }
        
        public double[,] DistanceMatrix
        {
            get { return distanceMatrix; }
            set { distanceMatrix = value; }
        }

        private void fillMatrix(IList<Point> ListOfCities)
        {
            for (int i = 0; i < citiesCount; i++)
            {
                for (int j = 0; j < citiesCount; j++)
                {
                    distanceMatrix[i,j] = pythagoras(ListOfCities.ElementAt(i), ListOfCities.ElementAt(j));
                }
            }
        }

        private double pythagoras(Point X, Point Y)
        {
            Point Z = new Point(Y.X, X.Y);
            int length_X_Z = Math.Abs(X.X - Z.X);
            int length_Y_Z = Math.Abs(Y.Y - Z.Y);
            double ret = Math.Sqrt(Math.Pow((double)length_X_Z, 2) + Math.Pow((double)length_Y_Z, 2));

            return ret;
        }
    }
}
